package com.beney.ds.sorting;

import com.beney.ds.sorting.abs.AbstractSort;

public class InsertionSort extends AbstractSort {
    private InsertionSort() {
    }

    public static void sort(Comparable[] arr) {
        if (arr == null) return;
        int len = arr.length;
        for (int i = 0; i < len; ++i) {
            for (int j = i; j > 0 && isLess(arr, j, j-1); --j) {
                swap(arr, j, j - 1);
            }
        }
    }
}
